//
//  RXlog.m - a collection of RX
//  iMed
//
//  Created by Barry Press on 8/18/09.
//  Copyright 2009 Barry Press. All rights reserved.
//

#import "RXlog.h"
#import "Constants.h"
#import "Meds.h"

@implementation RXlog

#pragma mark Collection methods
// ---------------------------------------------- addObject --------------------
- (void)addObject:(RX*)anObject
{
	NSAssert(rxs != NULL, @"NULL array pointer in rxs:addObject");
	[rxs addObject:anObject];
}

// ---------------------------------------------- count ------------------------
- (int)count
{
	NSAssert(rxs != NULL, @"NULL array pointer in rxs:count");
	return [rxs count];
}

// ---------------------------------------------- objectAtIndex ----------------
- (RX*)objectAtIndex:(int)index
{
	NSAssert(rxs != NULL, @"NULL array pointer in rxs:objectAtIndex");
	return [rxs objectAtIndex:index];
}

// ---------------------------------------------- removeAllObjects -------------
- (void)removeAllObjects
{
	NSAssert(rxs != NULL, @"NULL array pointer in rxs:removeAllObjects");
	[rxs removeAllObjects];
}

// ---------------------------------------------- removeObject -----------------
- (void)removeObject:(NDCitem*)anObject
{
	NSAssert(rxs != NULL, @"NULL array pointer in rxs");
	[rxs removeObject:anObject];
}

#pragma mark Archiving methods

// ---------------------------------------------- dealloc ----------------------
- (void)dealloc
{
	NSAssert(rxs != NULL, @"NULL array pointer in rxs:removeObject");
	[rxs release];
	rxs = NULL;
	[super dealloc];
}

// ---------------------------------------------- init -------------------------
- (id)init
{
	[super init];
	rxs = [[[NSMutableArray alloc] init] retain];
	NSAssert(rxs != NULL, @"NULL array pointer in rxs:init");
	return self;
}

// ---------------------------------------------- encodeWithCoder --------------
- (void)encodeWithCoder:(NSCoder *)coder
{
	NSAssert(rxs != NULL, @"NULL array pointer in rxs:encodeWithCoder");
	[coder encodeObject:rxs forKey:@"rxsArray"];
}

// ---------------------------------------------- initWithCoder ----------------
- (id)initWithCoder:(NSCoder *)coder
{
	[super init];
	rxs = [[coder decodeObjectForKey:@"rxsArray"] retain];
	NSAssert(rxs != NULL, @"NULL array pointer in rxs:initWithCoder");
	return self;
}


@end
